/**
 * 工具服务模块
 * @author HalRui
 * @version 1.0.0
 * @description 提供通用的工具函数，包括邮件验证码发送和随机验证码生成等功能
 * @date 2025年9月27日
 */

const mailService = require("../utils/mail-service");

module.exports = {
    sendMailCode : function(mail, code){
        //to, subject, content, isHtml
        let subject = "【验证码】您的注册验证码" ;
        let content = `
           <h1>你的验证码 : ${code}</h1>
        `;
        let isHtml = true;
        return mailService(mail,subject,content,isHtml);
    },
    createCode : function(length = 6){
        const code = "";
        const [max,min] = [Number("9".repeat(length)),Number("1".repeat(length))]

        return String(parseInt(Math.random() * (max - min) + min));
    },
}